﻿namespace WardenMonitor
{

    // from http://www.skullsecurity.org/wiki/index.php/Crypto_and_Hashing
    // License: unknown
    public static class RC4
    {
        public static byte[] Crypt(byte[] key, byte[] data)
        {
            for (int i = 0; i < data.Length; i++)
            {
                key[0x100]++;
                key[0x101] += key[key[0x100] & 0x0FF];
                byte temp = key[key[0x101] & 0x0FF];
                key[key[0x101] & 0x0FF] = key[key[0x100] & 0x0FF];
                key[key[0x100] & 0x0FF] = temp;

                data[i] = (byte)(data[i] ^ key[(key[key[0x101] & 0x0FF] + key[key[0x100] & 0x0FF]) & 0x0FF]);
            }

            return data;
        }
    }

}